home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / EDITSDI.PAK / WINMAIN.C < prev   
C/C++ Source or Header  |  1997-05-06  |  4KB  |  121 lines

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1995  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. //  MODULE:   winmain.c
  9. //
  10. //  PURPOSE:   Calls initialization functions and processes the message loop
  11. //
  12. //
  13. //  PLATFORMS: Windows 95, Windows NT, Win3.1
  14. //
  15. //  FUNCTIONS:
  16. //    WinMain() - calls initialization functions, processes message loop
  17. //
  18. //  COMMENTS:
  19. //
  20. //
  21.  
  22. #include <windows.h>            // required for all Windows applications
  23. #ifdef WIN16
  24. #include "win16ext.h"           // required only for win16 applications
  25. #endif
  26. #include "globals.h"            // prototypes specific to this application
  27.  
  28. //
  29. //  FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  30. //
  31. //  PURPOSE: calls initialization function, processes message loop
  32. //
  33. //  PARAMETERS:
  34. //
  35. //    hInstance - The handle to the instance of this application that
  36. //          is currently being executed.
  37. //
  38. //    hPrevInstance - The handle to the instance of this application
  39. //          that was last executed.  If this is the only instance
  40. //          of this application executing, hPrevInstance is NULL.
  41. //          In Win32 applications, this parameter is always NULL.
  42. //
  43. //    lpCmdLine - A pointer to a null terminated string specifying the
  44. //          command line of the application.
  45. //
  46. //    nCmdShow - Specifies how the main window is to be diplayed.
  47. //
  48. //  RETURN VALUE:
  49. //    If the function terminates before entering the message loop,
  50. //      return FALSE.
  51. //    Otherwise, return the WPARAM value sent by the WM_QUIT message.
  52. //
  53. //
  54. //  COMMENTS:
  55. //
  56. //    Windows recognizes this function by name as the initial entry point
  57. //    for the program.  This function calls the application initialization
  58. //    routine, if no other instance of the program is running, and always
  59. //    calls the instance initialization routine.  It then executes a
  60. //    message retrieval and dispatch loop that is the top-level control
  61. //    structure for the remainder of execution.  The loop is terminated
  62. //    when a WM_QUIT  message is received, at which time this function
  63. //    exits the application instance by returning the value passed by
  64. //    PostQuitMessage().
  65. //
  66. //    If this function must abort before entering the message loop, it
  67. //    returns the conventional value NULL.
  68. //
  69.  
  70. #pragma argsused
  71. int APIENTRY WinMain(
  72.     HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow
  73. )
  74. {
  75.     MSG msg;
  76.     HANDLE hAccelTable;
  77.  
  78.     // Other instances of app running?
  79.     if (!hPrevInstance)
  80.     {
  81.         // Initialize shared things
  82.         if (!InitApplication(hInstance))
  83.         {
  84.             return FALSE;               // Exits if unable to initialize
  85.         }
  86.     }
  87.  
  88.     // Perform initializations that apply to a specific instance
  89.     if (!InitInstance(hInstance, nCmdShow))
  90.     {
  91.         return FALSE;
  92.     }
  93.  
  94.     hAccelTable = LoadAccelerators(hInstance, szAppName);
  95.  
  96.     // Acquire and dispatch messages until a WM_QUIT message is received.
  97.     while (GetMessage(&msg, NULL, 0, 0))
  98.     {
  99.         //
  100.         // **TODO** Add other Translation functions (for modeless dialogs
  101.         //  and/or MDI windows) here.
  102.         //
  103.  
  104.         if (
  105.             !IsFindReplaceMsg(&msg) &&
  106.             !TranslateAccelerator(hwndMain, hAccelTable, &msg)
  107.         )
  108.         {
  109.             TranslateMessage(&msg);
  110.             DispatchMessage(&msg); 
  111.         }
  112.     }
  113.  
  114.     //
  115.     // **TODO** Call module specific instance free/delete functions here.
  116.     //
  117.  
  118.     // Returns the value from PostQuitMessage
  119.     return msg.wParam;
  120. }
  121.